package findRelativeRanks;


import java.util.Arrays;

public class Solution {
    static class Node{
        int index;
        int value;
        public Node(int index,int value){
            this.index = index;
            this.value = value;
        }
    }
    public String[] findRelativeRanks(int[] score) {
        Node[] nodes =new Node[score.length];
        for (int i = 0; i < nodes.length; i++) {
            nodes[i] = new Node(i,score[i]);
        }
        Arrays.sort(nodes, (o1, o2) -> o2.value - o1.value);
        String[] res = new String[score.length];
        for (int i = 0; i < nodes.length; i++) {
            if(i == 0){
                res[nodes[i].index] = "Gold Medal";
            }else if(i == 1) {
                res[nodes[i].index] = "Silver Medal";
            }else if(i == 2) {
                res[nodes[i].index] = "Bronze Medal";
            }else {
                res[nodes[i].index] = Integer.toString(i);
            }
        }
        return res;
    }
}
